module.exports = {
  /*
   ** Headers of the page
   */
  head: {
    title: 'zpz-vue-nuxt-cli',
    meta: [
      {charset: 'utf-8'},
      {name: 'viewport', content: 'width=device-width, initial-scale=1'},
      {hid: 'description', name: 'description', content: 'zpz-vue-nuxt-cli'}
    ],
    link: [
      {rel: 'icon', type: 'image/x-icon', href: '/favicon.ico'}
    ]
  },
  css: ['~assets/css/common.css', 'swiper/dist/css/swiper.css'],
  /*
   ** Customize the progress-bar color
   */
  loading: {color: '#13BA31', height: '2px'},
  /*
   ** Build configuration
   */
  build: {
    /*
     ** Run ESLINT on save
     */
    extend (config, ctx) {
      if (ctx.dev && ctx.isClient) {
        config.module.rules.push({
          enforce: 'pre',
          test: /\.(js|vue)$/,
          loader: 'eslint-loader',
          exclude: /(node_modules)/
        })
      }
    },
    vendor: [
    ]
  },
  plugins: [
    { src: '~/plugins/swiper.js', ssr: false }
  ],
  router: {
    middleware: 'auth'
  },
  modules: [
    '@nuxtjs/axios',
    '@nuxtjs/proxy'
  ],
  toast: {
    position: 'center'
  },
  axios: {
    baseURL: 'http://127.0.0.1:3000/api',
    requestInterceptor: (config, { store }) => {
      if (store.state.token) {
        config.headers.common['Authorization'] = store.state.token
      }
      return config
    }
  },
  proxy: {
    '/api': 'http://127.0.0.1:9090'
  }
}
